package com.greendizer.api.test.snippets;

import org.junit.Test;

import com.greendizer.api.client.BuyerClient;
import com.greendizer.api.dal.Collection;
import com.greendizer.api.resource.buyer.Buyer;
import com.greendizer.api.resource.buyer.Email;
import com.greendizer.api.resource.buyer.Invoice;


public class SecondSnippet {

  @Test
  public void SnippetTest() {
    Buyer buyer = new BuyerClient("oauth_token").getUser();
    Email email = buyer.getEmails().getById("example@domain.com");
    Collection<Invoice> invoices = email.getInvoices().search("total>>100|currency==USD");
    invoices.populate();

    for (Invoice invoice : invoices) {
      System.out.println(String.format("%s from %s", invoice.getName(), invoice.getSeller().getName()));
    }
  }
}
